//
//  BGMessageBeginTimeView.m
//  bigMall
//
//  Created by LTOVE on 16/7/26.
//  Copyright © 2016年 thinklev. All rights reserved.
//

#import "BGMessageBeginTimeView.h"

@implementation BGMessageBeginTimeView

+ (UIView *)initWithFrame:(CGRect)frame andBeginTime:(NSString *)beginTime andEndTime:(NSString *)endTime
{
    BGMessageBeginTimeView *view = [[BGMessageBeginTimeView alloc]initWithFrame:frame];
    //添加子控件
    [view setUpAllSubviewsWithView:view andBeginTime:beginTime andEndTime:endTime];
    return view;
}

- (void)setUpAllSubviewsWithView:(UIView *)view andBeginTime:(NSString *)beginTime andEndTime:(NSString *)endTime
{
    //增加开始时间
    UIView *views = [self addSubviewsWithFrame:CGRectMake(10, 10, 200, view.height -20) ImageName:@"begin.pgn" andTitleName:@"开始时间" andContentName:beginTime];
    [view addSubview:views];
    //增加结束时间
    UIView *endView = [self addSubviewsWithFrame:CGRectMake(view.width - 210, 10, 200, view.height - 20) ImageName:@"end.png" andTitleName:@"报名截止" andContentName:endTime];
    [view addSubview:endView];
}

- (UIView *)addSubviewsWithFrame:(CGRect)frame ImageName:(NSString *)imageName andTitleName:(NSString *)titleName andContentName:(NSString *)contentName
{
    UIView *view = [[UIView alloc]initWithFrame:frame];
//    view.size
    UIImageView *imgViewBeg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 21, 21)];
//#warning 增加设置imageView图片
    [imgViewBeg setImage:[UIImage imageNamed:imageName]];
    imgViewBeg.backgroundColor = [UIColor redColor];
    [view addSubview:imgViewBeg];
    UILabel *begTitleLabel = [[UILabel alloc]init];
    begTitleLabel.text = titleName;
    begTitleLabel.font = BGContenttextSize;
    begTitleLabel.textColor = BGtextGraykColor;
    begTitleLabel.x = CGRectGetMaxX(imgViewBeg.frame);
    begTitleLabel.centerY = imgViewBeg.centerY;
    [begTitleLabel sizeToFit];
    [view addSubview:begTitleLabel];
    UILabel *contentLabel = [[UILabel alloc]init];
    contentLabel.text = contentName;
    contentLabel.font = BGTitleSize;
    contentLabel.textColor = [UIColor blackColor];
    contentLabel.point = CGPointMake(imgViewBeg.x, CGRectGetMaxY(imgViewBeg.frame));
    [contentLabel sizeToFit];
    [view addSubview:contentLabel];
    return view;
    
}
@end
